home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
c80tcog.lbr
/
RANDI2.C
< prev
next >
Wrap
Text File
|
1985-08-09
|
640b
|
38 lines
/* randi2 - unsigned 16-bit pseudo-random numbers */
/*
based on Knuth, Donald E. "The Art of Computer Programming"
Vol 2, 2nd. ed. 1981.
William G. Hutchison, Jr.
P.O. Box 278
Exton, PA 19341-0278
U.S.A.
CompuServe 70665,1307
CO CNODE #1080
*/
#include "randi1.c" /* above */
randi2(x)
unsigned *x;
{
#define TSIZE 55
static unsigned r, t[TSIZE];
static int p= -1;
static int q= 0;
if (p < 0) {
for (p= q= TSIZE-1; q >= 0; q--)
t[q]= randi1(*x);
q= 23;
}
r= (t[p]+= t[q]);
if (p-- == 0) p= TSIZE-1;
if (q-- == 0) q= TSIZE-1;
return (r);
#undef TSIZE
} /* end of randi2 */